Skip to main content

All Questions

0votes
1answer
83views

Changing the value of values after a particular index along one axis in a 3D numpy array

I have a 3d array of format given below. The below is the one sample of the 3D array, like it , it contain more than 1000. sample shape of the 3D array is (1000 x 10 x 5) The image contain one element ...
skywalker's user avatar
0votes
0answers
112views

Pandas data frame returning 1D multiple arrays to multiple Data Frame rather than single data frame

I have an images data set which I have converted into NumPy array and getting total counts of pixels in individual images. I am using below code for this purpose: data_custom_script = images ...
Sentinel_hub's user avatar
0votes
1answer
169views

Can I replace values in ndarray by np.where with condition?

I have a 2d array,such as 5. , 6. , 7. , 8. , 9. ], [-0.6810069 , -0.61737489, 0.09869664, -0.95659638, 0.54052288, -0.21486195, -0....
Wrenb's user avatar
0votes
2answers
233views

How to average data for a variable over a number of timesteps

I was wondering if anyone could shed some light into how I can average this data: I have a .nc file with data (dimensions: 2029,64,32) which relates to time, latitude and longitude. Using these ...
Matlaboverflow's user avatar
4votes
1answer
85views

How can you multiply all the values within a 2D df with all the values within a 1D df separately?

I'm new to numpy and I'm currently working on a modeling project for which I have to perform some calculations based on two different data sources. However until now I haven't managed to figure out ...
user avatar
2votes
1answer
139views

ndarray delete rows by indexes from condition in another array

I have two ndarrays, where the length of the first dimension of X is the same as the size of y: X = np.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9], [3, 6, ...
Cranjis's user avatar
  • 2,010
0votes
1answer
86views

Multidimensional numpy.ndarray from multi-indexed pandas.DataFrame

I want to produce a 3-dimensional numpy.ndarray from a multi-indexed pandas.DataFrame. More precisely, say I have: df = pd.DataFrame([[1, '1' , 1, 10], [1, '2', 2, 20], [2, '1', 5, 30]], columns=['x',...
user0's user avatar
0votes
0answers
56views

DataFrame with multidimensional values [duplicate]

I want to create a DataFrame that contains not 1-dimensional arrays in one or more columns. This is the example: array1 = numpy.array([1,2]) array2 = numpy.array([[1,2],[3,4]]) A B 1 [1, 2] ...
maurock's user avatar
5votes
1answer
9kviews

Pandas vs. Numpy Dataframes

Look at these few lines of code: df2 = df.copy() df2[1:] = df[1:]/df[:-1].values -1 df2.ix[0, :] = 0 Our instructor said we need to use the .values attribute to access the underlying numpy array, ...
MadHatter's user avatar
1vote
1answer
241views

take the year from date type in a pandas dataframe column [duplicate]

I have year data in a pandas dataframe as following: 0 06/09/1937 1 22/11/1972 and i would like to extract only the year data: 0 1937 1 1972 My code: features["year"] = df["...
Cheng's user avatar
1vote
0answers
87views

pandas Selecting/sampling at different interval frequencies

I have a 2d array/DF >>> X_df.shape Out[36]: (138, 2164) Each row of this array has values uptill a given column (different for all rows) followed by nans: >>> X_df.head(1).T Out[...
dayum's user avatar
  • 1,105
11votes
1answer
15kviews

pandas, convert DataFrame to MultiIndex'ed DataFrame

I have a pandas.DataFrame that I want to convert to a MultiIndexed pandas.DataFrame. import numpy import pandas import itertools xs = numpy.linspace(0, 10, 100) ys = numpy.linspace(0, 0.1, 20) zs = ...
johnbaltis's user avatar
2votes
2answers
2kviews

Selecting columns from numpy recarray

I have an object from type numpy.core.records.recarray. I want to use it effectively as pandas dataframe. More precisely, I want to use a subset of its columns in order to obtain a new recarray, the ...
Baron Yugovich's user avatar
3votes
3answers
7kviews

easy multidimensional numpy ndarray to pandas dataframe method?

Having a 4-D numpy.ndarray, e.g. myarr = np.random.rand(10,4,3,2) dims={'time':1:10,'sub':1:4,'cond':['A','B','C'],'measure':['meas1','meas2']} But with possible higher dimensions. How can I ...
TNT's user avatar
  • 2,511
22votes
3answers
56kviews

How to create pandas dataframes with more than 2 dimensions?

I want to be able to create n-dimensional dataframes. I've heard of a method for 3D dataframes using panels in pandas but, if possible, I would like to extend the dimensions past 3 dims by combining ...
O.rka's user avatar
  • 30.8k

close